<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Return an array of column types from a particular table</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.sqlite-fetch-column-types" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">sqlite_fetch_column_types</h1>
  <h1 class="refname">SQLiteDatabase::fetchColumnTypes</h1>
  <p class="verinfo">(PHP 5 &lt; 5.4.0)</p><p class="refpurpose"><span class="refname">sqlite_fetch_column_types</span> -- <span class="refname">SQLiteDatabase::fetchColumnTypes</span> &mdash; <span class="dc-title">
   Return an array of column types from a particular table
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.sqlite-fetch-column-types-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>sqlite_fetch_column_types</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$table_name</code></span>
   , <span class="methodparam"><span class="type">resource</span> <code class="parameter">$dbhandle</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$result_type</code><span class="initializer"> = SQLITE_ASSOC</span></span>
  ] ) : <span class="type">array</span></div>

  <p class="para rdfs-comment">面向对象风格 (method):</p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SQLiteDatabase::fetchColumnTypes</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$table_name</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$result_type</code><span class="initializer"> = SQLITE_ASSOC</span></span>
  ] ) : <span class="type">array</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>sqlite_fetch_column_types()</strong></span> returns an array of column
   data types from the specified <code class="parameter">table_name</code> table.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.sqlite-fetch-column-types-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">table_name</code></dt>

     <dd>

      <p class="para">
       The table name to query.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">dbhandle</code></dt>

     <dd>

      <p class="para">
       The SQLite Database resource; returned from <span class="function"><a href="sqlite_open.html" class="function">sqlite_open()</a></span>
       when used procedurally.  This parameter is not required
       when using the object-oriented method.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">result_type</code></dt>

     <dd>

      <p class="para">
       The optional <code class="parameter">result_type</code> parameter accepts a
       constant and determines how the returned array will be indexed. Using
       <strong><code>SQLITE_ASSOC</code></strong> will return only associative indices
       (named fields) while <strong><code>SQLITE_NUM</code></strong> will return only
       numerical indices (ordinal field numbers).
       <strong><code>SQLITE_ASSOC</code></strong> is the default for
       this function.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.sqlite-fetch-column-types-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an array of column data types; <strong><code>FALSE</code></strong> on error.
  </p>
  <p class="para">由
<strong><code>SQLITE_ASSOC</code></strong> 与 <strong><code>SQLITE_BOTH</code></strong>
返回的列名会依照 <a href="sqlite.configuration.html#ini.sqlite.assoc-case" class="link">sqlite.assoc_case</a>
配置选项的值决定大小写。</p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.sqlite-fetch-column-types-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.1.0</td>
       <td>Added <code class="parameter">result_type</code></td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.sqlite-fetch-column-types-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2540">
    <p><strong>Example #1 Procedural example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$db&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sqlite_open</span><span style="color: #007700">(</span><span style="color: #DD0000">'mysqlitedb'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">sqlite_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$db</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'CREATE&nbsp;TABLE&nbsp;foo&nbsp;(bar&nbsp;varchar(10),&nbsp;arf&nbsp;text)'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cols&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sqlite_fetch_column_types</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$db</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SQLITE_ASSOC</span><span style="color: #007700">);<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$cols&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$column&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$type</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Column:&nbsp;</span><span style="color: #0000BB">$column</span><span style="color: #DD0000">&nbsp;&nbsp;Type:&nbsp;</span><span style="color: #0000BB">$type</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2541">
    <p><strong>Example #2 Object-oriented example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$db&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SQLiteDatabase</span><span style="color: #007700">(</span><span style="color: #DD0000">'mysqlitedb'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">query</span><span style="color: #007700">(</span><span style="color: #DD0000">'CREATE&nbsp;TABLE&nbsp;foo&nbsp;(bar&nbsp;varchar(10),&nbsp;arf&nbsp;text)'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cols&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$db</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fetchColumnTypes</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">SQLITE_ASSOC</span><span style="color: #007700">);<br /><br />foreach&nbsp;(</span><span style="color: #0000BB">$cols&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$column&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$type</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Column:&nbsp;</span><span style="color: #0000BB">$column</span><span style="color: #DD0000">&nbsp;&nbsp;Type:&nbsp;</span><span style="color: #0000BB">$type</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Column: bar  Type: VARCHAR
Column: arf  Type: TEXT
</pre></div>
    </div>
   </div>
  </p>
 </div>

</div></div></div></body></html>